#ifndef QUAKE_SERVER_H
#define QUAKE_SERVER_H

#pragma warning (disable:4786)

#include <string>
#include <map>
#include <ace/singleton.h>
#include <ace/Null_Mutex.h>
#include <ace/SOCK_Dgram.h>
#include <ace/Task_T.h>

#include "Demo.h"
#include "Script.h"

class ClientCommand
{
public:
	ClientCommand();

	bool		HasMovement;
	byte		Flags;
	double		Speed[3];
	double		Angles[3];
	int			Impulse;

	std::string ConsoleCommand;
};




class QuakeServer
{
public:
	QuakeServer(Demo &D,Script& S);
	bool AcceptClient();
	bool RunEditing();
	bool Process(Demo& OutDemo);
private:
	void SendReliableBlock();
	void SendUnreliableBlock();
	bool GetClientMessage(ClientCommand& Cmd,bool Wait);
	void BeginSession();

	long m_SentOrder;
	Demo&				m_Demo;
	Script&				m_Script;
	ACE_SOCK_Dgram		m_ClientSocket;
	ACE_INET_Addr		m_ClientAddress;
	float				m_Time;

	int					m_Speed; // -3..3

	bool				m_SnapToRoute;
};




#endif 
